CREATE PROCEDURE [dbo].[History_ClearOldData]
	@RangeReviewId int
AS

DELETE HistoryDetails
FROM HistoryDetails hd
INNER JOIN History h on hd.HistoryId = h.Id
WHERE h.RangeReviewId = @RangeReviewId


DELETE FROM History where RangeReviewId = @RangeReviewId;
